package com.ywl.task.controller;

import com.ywl.task.pojo.Project;
import com.ywl.task.service.ProjectService;
import com.ywl.task.util.pojo.QdResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 严伟伦
 * @Company 无
 * @Description
 * @Date: 2024/9/5 20:05
 */
@RestController
@RequestMapping("/project")
@CrossOrigin
public class ProjectController {
    @Autowired
    private ProjectService projectService;
    @GetMapping("/list")
    public QdResult list(Project project, @RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10")int limit){
        return projectService.queryByPage(project,page,limit);
    }

    @GetMapping("/deleteList")
    public QdResult selectDeletes(Project project, @RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10")int limit){

        return projectService.selectDeletes(project,page,limit);
    }

    @PostMapping("/save")
    public QdResult addProject(@RequestBody Project project){
        System.out.println("33333333333333333333333333333333" + project);
        return projectService.addProject(project);
    }

    @GetMapping("/projectIdList")
    public QdResult selectProjectById(@RequestParam("projectId") String projectId){

        return projectService.selectProjectById(projectId);
    }

    @PutMapping("/update")
    public QdResult updateProjectById(@RequestBody Project project){
        return projectService.updateProjectById(project);
    }

    @PutMapping("/delete")
    public QdResult deleteProject(@RequestParam("projectId") String projectId){
        return projectService.deleteProject(projectId);
    }


    @PutMapping("/file")
    public QdResult updateFile(@RequestParam("projectId") String projectId){
        return projectService.updateFile(projectId);
    }


    @PutMapping("/fileRestore")
    public QdResult updateFileRestore(@RequestParam("projectId") String projectId){
        return projectService.updateFileRestore(projectId);
    }

    @PutMapping("/releases")
    public QdResult updateReleases(@RequestBody String [] projectIds){
        return projectService.updateReleases(projectIds);
    }

    @PutMapping("/files")
    public QdResult updateFiles(@RequestBody String [] projectIds){
        return projectService.updateFiles(projectIds);
    }


    @PutMapping("/deletes")
    public QdResult updateDeletes(@RequestBody String [] projectIds){
        return projectService.updateDeletes(projectIds);
    }





}
